class Solution:
    def rotate(self, matrix: list[list[int]]) -> None:
        n = len(matrix)
        for i in range(n):
            for j in range(n):
                matrix[i][j],matrix[n - 1 - i][j] = matrix[n - 1 - i][j],matrix[i][j]
        for i in range(n):
            for j in range(n):
                matrix[i][j],matrix[j][j] = matrix[j][i],matrix[i][j]
